{include file="public/header" /}
<link rel="stylesheet" href="/static/admin/css/welcome.css" media="all">
<style>
    .card-rows-fast > div {
        display: flex;
        flex-direction: column
    }

    .card-rows-fast > div p {
        padding: 10px 0;
        font-size: 12px
    }

    .for-updates {
        margin-left: 10px;
    }

    .for-updates .layui-icon {
        color: #00a2d4;
        margin-right: 10px;
    }

    .for-updates > span {
        color: #00a2d4;
        text-decoration: underline;
        cursor: pointer;
        margin-right: 1px;
    }

    .for-updates > i, .layui-icon {
        font-size: 13px;
    }

    .new-version {
        color: #e81123;
        text-decoration: underline;
        cursor: pointer;
    }

</style>
<body>
<div class="layui-fluid layui-anim layui-leftbit">
    <div class="layui-row layui-col-space8">
        <div class="layui-col-md3">
            <div class="layui-card h220">
                <div class="card-rows">
                    <div class="layui-card-header">⚙️ 系统信息</div>
                    <div class="layui-row card-rows-fast">
                        <div class="layout">
                            <p style="">系统名称：{:cache('system')['web_site_title']}</p>
                            <p>系统域名：{:request()->domain()}</p>
                            <p>访问IP：{:request()->ip()}</p>
                            {if request()->ip() == '127.0.0.1'}
                            <div class="flex items-center ">
                                <p>版本：<span class="layui-badge">{:getBuilderConfig('version')}</span></p>
                                <p class="for-updates">
                                    <span lay-click="forUpdates">检查更新</span>
                                    <i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop layui-hide"></i>
                                </p>
                            </div>
                            <p class="new-version layui-hide"></p>
                            {else}
                            <p>版本：<span class="layui-badge">{:getBuilderConfig('version')}</span></p>
                            {/if}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
{include file="public/footer" /}
<script>
    layui.use(['methods', 'index', 'layer', 'jquery'], function () {
        var ly = layui.layer, methods = layui.methods, a = layui.jquery;
        methods.event.click(['forUpdates', 'updates'], function (data, that) {
            that.next().removeClass('layui-hide');
            methods.fetchGet('{:url("version/check")}', {}, function (e) {
                that.next().addClass('layui-hide');
                if (e.code === 1) {
                    a('.h220').css('height', '240px');
                    a('.new-version').html('<span lay-click="updates"><i class="layui-icon layui-icon-tips"></i> ' + e.msg + '，点击更新</span>').removeClass('layui-hide');
                } else {
                    ly.msg(e.msg);
                }
            }, false);
        }, function (data, that) {
            methods.confirm('确定要更新吗？', function () {
                methods.fetchGet('{:url("version/update")}', {}, function (e) {
                    e.code === 1 ? ly.msg(e.msg, {time: 1000}, function () {
                        parent.location.reload()
                    }) : ly.msg(e.msg);
                });
            });
        });
    });
</script>
</html>